#!/bin/bash

# Copyright (c) 2025 Battelle Energy Alliance, LLC.  All rights reserved.

if [[ -z $EXTRACTED_FILE_ENABLE_CLAMAV ]]; then
  EXTRACTED_FILE_ENABLE_CLAMAV=false
fi

if [[ -z $EXTRACTED_FILE_ENABLE_YARA ]]; then
  EXTRACTED_FILE_ENABLE_YARA=false
fi

if [[ -z $EXTRACTED_FILE_ENABLE_CAPA ]]; then
  EXTRACTED_FILE_ENABLE_CAPA=false
fi

if [[ -z $EXTRACTED_FILE_ENABLE_VTOT ]]; then
  [[ ${#VTOT_API2_KEY} -gt 1 ]] && EXTRACTED_FILE_ENABLE_VTOT=true || EXTRACTED_FILE_ENABLE_VTOT=false
fi

export EXTRACTED_FILE_ENABLE_CLAMAV
export EXTRACTED_FILE_ENABLE_YARA
export EXTRACTED_FILE_ENABLE_CAPA
export EXTRACTED_FILE_ENABLE_VTOT

EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR=${EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR:-/assets}
EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR_REQ_REPLACER=${EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR_REQ_REPLACER:-/assets}
[[ "${MALCOLM_PROFILE:-malcolm}" == "malcolm" ]] && \
  EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR_RESP_REPLACER=${EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR_RESP_REPLACER:-/extracted-files/assets} || \
  EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR_RESP_REPLACER=${EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR_RESP_REPLACER:-/assets}
export EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR
export EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR_REQ_REPLACER
export EXTRACTED_FILE_HTTP_SERVER_ASSETS_DIR_RESP_REPLACER

exec "$@"
